
from enum import Enum
from abc import abstractmethod


class BaseEnum(Enum):

    @staticmethod
    @abstractmethod
    def parse(index):
        pass


class RedisConnectType(Enum):

    Cluster = 1
    Client = 2


class TreeItemType(Enum):

    Cluster = 1
    Client = 2
    Node = 3
    Database = 4
    Key = 5


class TabComboBoxFormat(BaseEnum):

    Text = 0
    Json = 1

    @staticmethod
    def parse(index):
        if TabComboBoxFormat.Text.value == index:
            return TabComboBoxFormat.Text
        elif TabComboBoxFormat.Json.value == index:
            return TabComboBoxFormat.Json


class ConnectTabIndex(BaseEnum):

    Client = 0
    Cluster = 1